package healththink



import grails.test.mixin.*
import org.junit.*

/**
 * See the API for {@link grails.test.mixin.domain.DomainClassUnitTestMixin} for usage instructions
 */
@TestFor(Address)
class AddressTests {

    @Test
    void testAddress() {
          
        def add1 = HealthThink.getStaticAddress()
        mockForConstraintsTests(Address, [add1])
        def testAdd1 = new Address()
        assertFalse testAdd1.validate()
        assertEquals "nullable", testAdd1.errors["address"]
        assertEquals "nullable", testAdd1.errors["lga"]
        assertEquals "nullable", testAdd1.errors["state"]
		assertEquals null, testAdd1.errors["address2"]
           
        Address target = HealthThink.getStaticAddress()
        assertNotNull("(error)Address Target Address Null", target)
        assertNotNull("(error)Address Validation Was Not Successfull", target.validate())

        target = target.save(flush:true)
        Address expected = Address.findById(target.id)

        assertNotNull("(error)Address Target was not saved", target)
        assertNotNull("(error)Expected Address was null", expected)
        assertEquals("(error)Target and Expected are not Equal", target, expected)

        target.delete(flush:true)
    }
}
